package com.boc.ewr.util.file.enumeration;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.collection.SetUtils;

import java.util.Arrays;
import java.util.Optional;
import java.util.Set;

/**
 * 协议性质
 */
@Slf4j
public enum ProtocolTypeEnum {
    NOFOCUS("0", "非重点"),
    CONCERN("3", "关注"),
    FOCUS("4", "重点"),
    UNUSUAL("5", "异动"),
    SUSPICIOUS("6", "可疑"),
    HIGHRISK("7", "高风险");

    private String index;
    private String value;

    ProtocolTypeEnum(String index, String value) {

        this.index = index;
        this.value = value;
    }

    /**
     * 根据value获取枚举对象
     *
     * @param val
     * @return
     */
    public static ProtocolTypeEnum getIndexByValue(String val) {
        Optional<ProtocolTypeEnum> first = Arrays.stream(ProtocolTypeEnum.values()).filter(e -> e.getValue().equals(val)).findFirst();
        ProtocolTypeEnum expEnum = first.orElse(null);
        log.info("选择的枚举类型是：" + expEnum.toString());
        return expEnum;
    }

    /*非重点和关注是非重点类，其余为重点类*/
    // 非重点类 set集合
    public static Set<String> getNoFocusIndexSet() {
        return SetUtils.asSet(
                NOFOCUS.getIndex(),
                CONCERN.getIndex()
        );
    }

    // 重点类 set集合
    public static Set<String> getFocusIndexSet() {
        return SetUtils.asSet(
                FOCUS.getIndex(),
                UNUSUAL.getIndex(),
                SUSPICIOUS.getIndex(),
                HIGHRISK.getIndex()
        );
    }

    public String getIndex() {
        return index;
    }

    public void setIndex(String index) {
        this.index = index;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
